import {defineComponent, h, PropType, Fragment} from 'vue';
import {DataInfo, ChildProps} from '../resolve/types.ts';
import {renderChildren} from './render.ts';

/**
 * 渲染组件
 * @author zj
 * @date 2024/08/22
 */
export default defineComponent({
  name: 'FxRender',
  inheritAttrs: false,
  props: {
    info: {
      type: Object as PropType<DataInfo>,
      default: () => ({})
    },
    data: {
      type: Object as PropType<any>,
      default: () => ({})
    },
    children: {
      type: Array as PropType<Array<ChildProps>>,
      default: () => ([])
    }
  },
  emits: [],
  setup(props, context) {
    return () => {
      return h(Fragment, {}, renderChildren(props.children, props.info, props.data));
    };
  }
});